import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';

@Component({
  selector: 'app-tabs-card',
  templateUrl: './tabs-card.component.html',
  styleUrls: ['./tabs-card.component.scss']
})
export class TabsCardComponent implements OnInit {

  @Input() list = null;
  @Output() currentSelectTab = new EventEmitter<any>();
  currentTab = '';

  constructor() { }

  ngOnInit() {
    // 判断条件是否严谨？
    if (this.list) {
      this.currentTab = this.list[0].title;
    }
  }

  // 更换tab项
  changeItem(item) {
    this.currentTab = item.title;
    // 传出！
    this.currentSelectTab.emit(item);
  }

}
